<?php
/**
 * Enum class for all available weekend options
 *
 * @access 	public
 * @author 	rob
 * @copyright	ResMania 2009 all rights reserved.
 * @version	1.0
 * @link		http://developer.resmania.com/api
 * @since  	11-2010
 */
class RM_HospitalityPrices_Weekend {
    // This values indicates what days are a weekend:
    // 2 is a monday,
    // 128 is a sunday
    // That values are also in the database: in rm_daily_prices_config table row with name = 'weekend_days' in 'metainfo' field
    const fridaySaturday = 96;          //0110000
    const saturdaySunday = 192;         //1100000
    const fridaySaturdaySunday = 224;   //1110000
    const sunday = 128;                 //1000000

    public static $weekendOptions = array(
        self::fridaySaturday => 'WeekendDaysFriSat',
        self::saturdaySunday => 'WeekendDaysSatSu',
        self::fridaySaturdaySunday => 'WeekendDaysFriSatSun',
        self::sunday => 'WeekendDaysSun'
    );

    /**
     * Check is the input day is a weekend
     *
     * @param int $weekend Config weekend value
     * @param int $weekDay weekday number
     * @return bool
     */
    static function isWeekend($weekend, $weekDay)
    {
        $dayNumberPow = pow(2, $weekDay);        
        return (($weekend & $dayNumberPow) == $dayNumberPow);
    }   
}